<?php
/**
 * 模块启动文件
 */
namespace addons\navigation;
use system\Addon;

class Navigation extends Addon {
    public function getName()
    {
        return 'navigation';
    }

    public function getVersion()
    {
        return [
            '1.0.0'
        ];
    }

    public function getAuthor()
    {
        return 'Colin';
    }

    public function getDesc()
    {
        return '导航管理';
    }

    public function install()
    {
        $sql['1.0.0'] = "CREATE TABLE IF NOT EXISTS `@navigation`(
id int unsigned not null auto_increment primary key , 
title varchar(40) not null comment '导航名' , 
pid int(0) unsigned null default 0 comment '上级导航' , 
url varchar(255) null comment '跳转地址' , 
sort int null comment '排序值' , 
create_time int(10) default 0 comment '添加时间',
key pid(`pid`)
)engine=myisam charset=utf8 comment='导航表';";
        return $sql;
    }

    public function uninstall()
    {
        $sql['1.0.0'] = "DROP TABLE `@navigation`;";
        return $sql;
    }

    public function onInitMenu(&$data = []){
        return [
            [
                'name'  => 'navigation',
                'title' => '导航管理',
                'icon'  => 'layui-icon-set',
                'list'  => [
                    ['name' => 'navigationList', 'title' => '导航列表', 'auth_name' => 'Navigation', 'action' => 'index' , 'jump' => '---navigation/index'],
                ]
            ],
        ];
    }
}